package com.clg.javafx.controllers

import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.Table
import org.jetbrains.exposed.sql.transactions.transaction
import tornadofx.Controller

/**
 * Created by 林光 on 2017/4/17.
 */
class DbController:Controller(){


    fun loadAllTable(): ArrayList<Table>{
        var tables = ArrayList<Table>()

        Database.connect("jdbc:mysql://localhost:3306/test", driver = "com.mysql.jdbc.Driver",user="root",password = "root")
        transaction {
            val tableRs = this.db.metadata.getTables(null,null,null, arrayOf("TABLE"))
            while(tableRs.next()){
                tables.add(Table(name=tableRs.getString("TABLE_NAME")))
            }
        }
        return tables
    }
}